// 模拟数据库数据
const posts = [
  {
    id: 1,
    title: "Vue.js 开发技巧",
    excerpt: "掌握 Vue.js 开发中的实用技巧和最佳实践，提升开发效率和代码质量。",
    category: "技术",
    date: "2024-01-15",
    image: "https://picsum.photos/400/300?random=1",
    tags: ["Vue.js", "前端", "最佳实践"],
    slug: "vuejs-development-tips",
    readTime: 8,
    content: "这是 Vue.js 开发技巧文章的详细内容..."
  },
  {
    id: 2,
    title: "CSS Grid 布局实战技巧",
    excerpt: "掌握 CSS Grid 布局的核心概念和实用技巧，创建响应式网页布局变得简单高效。",
    category: "前端",
    date: "2024-01-12",
    image: "https://picsum.photos/400/300?random=2",
    tags: ["CSS", "布局", "响应式"],
    slug: "css-grid-layout-guide",
    readTime: 6,
    content: "这是 CSS Grid 布局实战技巧文章的详细内容..."
  },
  {
    id: 3,
    title: "JavaScript 异步编程模式",
    excerpt: "从回调函数到 async/await，全面了解 JavaScript 异步编程的演进和最佳实践。",
    category: "JavaScript",
    date: "2024-01-10",
    image: "https://picsum.photos/400/300?random=3",
    tags: ["JavaScript", "异步", "编程"],
    slug: "javascript-async-patterns",
    readTime: 10,
    content: "这是 JavaScript 异步编程模式文章的详细内容..."
  }
]

// GET /api/posts/[slug] - 获取单篇文章
export default defineEventHandler(async (event) => {
  const slug = getRouterParam(event, 'slug')
  
  const post = posts.find(p => p.slug === slug)
  
  if (!post) {
    throw createError({
      statusCode: 404,
      statusMessage: '文章未找到'
    })
  }
  
  return post
}) 